Vpa.apply(String.prototype, {
    isSpace : function(){
        return (this.trim()).length <= 0;
    },

    getShort : function(len){
        len = len || 120;
        var str = this.stripTags(),
            p0 = str.indexOf(". "),
            p1 = str.indexOf("。");
        p0 = p0 < 1 ? 117 : (p0>115 ? 117 : (p0+2));
        p1 = p1 < 1 ? 117 : (p1>115 ? 117 : (p1+2));
        var p = p0 < p1 ? p0 : p1;
        var result = str.substring(0,p);
        if(result.length < str.length)
            result += '...';
        return result;
        
    },

    stripTags : function(){
        return this.replace(/<[^>]+>/g, '');
    },
    
    getByteLength : function(){
        return this.replace(/[^\x00-\xff]/g, "ci").length;
    },

    removeBrackets : function(){
        var _s = this.trim(),
            start = 0,
            end = _s.length;
        if(_s.charAt(0) == "{")
            start = 1;
        if(_s.charAt(end-1) == "}")
            end--;
        return _s.substring(start,end);
    },
    
    divideByWhite : function(part){
        var _s = this.trim();
        if(part<=1)
            return [_s.substring(0)];
            
        var strParts = [];
        var SPACE = 0,
            TEXT = 1;
        var state = SPACE,
            isEnd = false,
            start = 0;
        for(var i=0,len=_s.length;i<len;i++){
            var isSpace = _s.charAt(i).isSpace();
            switch(state){
                case SPACE:
                    if(!isSpace){
                        start = i;
                        if(part == 1){
                            strParts.push(_s.substring(start));
                            part--;
                            isEnd = true;
                            break;
                        }
                        state = TEXT;
                    }
                    break;
                case TEXT:
                    if(isSpace){
                        strParts.push(_s.substring(start,i));
                        state = SPACE;
                        part--;
                    }
            }
            if(isEnd)
                break;
        }
        if(part>0){
            strParts.push(_s.substring(start));
            part--;
        }
        while(part>0){
            strParts.push("");
            part--;
        }
        
        return strParts;
    }
});
